name: MindsDB Release Candidate Acceptance Tests

on:
  pull_request:
    branches: [stable]
    paths-ignore:
      - 'docs/**'
      - 'README.md'

jobs:
  tutorials_test:
    name: Learning Hub Acceptance Tests
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3.5.3
    - name: Set up Python 3.8
      uses: actions/setup-python@v4.7.0
      with:
        python-version: 3.8
    - name: Install dependencies
      run: |
        pip install .
        pip install .[huggingface] # Right now the learning hub tests rely on huggingface and lightwood. We should mock them
        pip install .[lightwood]
        pip install -r requirements/requirements-test.txt
      shell: bash
      env:
        ACCESS_KEY:  ${{ secrets.GH_ACCESS_KEY }}
        mindsdb_github_masterkey: ${{secrets.mindsdb_github_masterkey}}
    - name: Run Learning Hub Tests
      run: |
          # Currently requires a DB to be running. New testing system is being set up
          # echo -e "\n===============MySQL Handler===============\n"
          # pytest -svx mindsdb/integrations/handlers/mysql_handler/

          # Currently requires a DB to be running. New testing system is being set up
          # echo -e "\n===============PostgreSQL Handler===============\n"
          # pytest -svx mindsdb/integrations/handlers/postgres_handler/

          echo -e "\n===============MariaDB Handler===============\n"
          pytest -svx tests/handler_tests/test_mariadb_handler.py

          echo -e "\n===============File Handler===============\n"
          pytest -svx mindsdb/integrations/handlers/file_handler/

          echo -e "\n===============Home Rental Home Prices===============\n"
          pytest -vx tests/integration_tests/flows/test_home_rental_prices_tutorial.py

          echo -e "\n===============Forecast Quaterly House Sales===============\n"
          pytest -vx tests/integration_tests/flows/test_forecast_quaterly_house_tutorial.py

          echo -e "\n===============Predict Text Sentiment Wih Huggingface===============\n"
          pytest -vx tests/integration_tests/flows/test_predict_text_sentiment_huggingface_tutorial.py

          echo -e "\n===============Predict Text Sentiment Wih OpenAI===============\n"
          pytest -vx tests/integration_tests/flows/test_predict_text_sentiment_openai_tutorial.py
      shell: bash
      env:
        CHECK_FOR_UPDATES: False
        OPENAI_API_KEY: ${{secrets.OPENAI_API_KEY}}

  microservice_mode_test:
    needs: tutorials_test
    name: Microservice Mode Tests
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3.5.3
    - name: Set up Python 3.8
      uses: actions/setup-python@v4.7.0
      with:
        python-version: 3.8
    - name: Install dependencies
      run: |
        pip install .
        pip install -r requirements/requirements-test.txt
      shell: bash
      env:
        ACCESS_KEY:  ${{ secrets.GH_ACCESS_KEY }}
        mindsdb_github_masterkey: ${{secrets.mindsdb_github_masterkey}}
          # - name: Build docker-compose images
          #   run: |
          #     docker-compose -f ./docker/docker-compose-ci.yml build
          # - name: Run Learning Hub Tests
          #   run: |
          #       echo -e "\n===============HTTP API===============\n"
          #       env MICROSERVICE_MODE=true pytest -vx tests/integration_tests/flow/test_http.py
          #   shell: bash
          #   env:
          #     CHECK_FOR_UPDATES: False
          #     OPEN_AI_API_KEY: ${{secrets.OPEN_AI_API_KEY}}
